package miravalles.chip;

import android.content.Intent;
import android.net.Uri;
import android.provider.Browser;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.PopupWindow;

public class EscuchadorFila implements OnClickListener, OnTouchListener {
	
	private Apunte apunte;
	private boolean par;
	
	public EscuchadorFila(Apunte apunte, boolean par) {
		this.apunte=apunte;
		this.par=par;
	}
	
	public void setBackgroundColor(View v) {
		if(par) {
			v.setBackgroundColor(0xFF223344);
		} else {
			v.setBackgroundColor(0xFF112233);
		}
	}
	
	public void onClick(View v) {		
		if(apunte.getLatitud()!=null) {
			Intent browserIntent = new Intent(
					Intent.ACTION_VIEW, 
					Uri.parse("http://maps.google.com?q=" + 
							apunte.getLatitud() + "," + apunte.getLongitud()));
			v.getContext().startActivity(browserIntent);		
		}		
	}
	
	public boolean onTouch(View v, MotionEvent event) {		
		if(event.getAction()==MotionEvent.ACTION_DOWN) {
			v.setBackgroundColor(0xFF884422);
		} else {
			setBackgroundColor(v);
		}
		return false;
	}
}
